package org.scribe.model;

import java.io.Serializable;
import java.util.Hashtable;

/**
 * Represents an OAuth token (either request or access token) and its secret
 *
 * @author Pablo Fernandez
 */
public class Token implements Serializable {
    private static final long serialVersionUID = 715000866082812683L;

    private final String token;
    private final String secret;

    private Hashtable<String, String> other;

    /**
     * Default constructor
     *
     * @param token  token value
     * @param secret token secret
     */
    public Token(String token, String secret) {
        this.token = token;
        this.secret = secret;
    }

    public String getToken() {
        return token;
    }

    public String getSecret() {
        return secret;
    }

    public void addOther(String n, String v) {
        if (other == null) {
            other = new Hashtable<String, String>();
        }
        other.put(n, v);
    }

    public String getOther(String n) {
        String ret = null;
        if (n != null && other != null) {
            ret = other.get(n);
        }
        return ret;
    }

    public Hashtable<String, String> getOthers() {
        return other;
    }

    @Override
    public String toString() {
        return String.format("Token[%s , %s]", token, secret);
    }
}
